import Vue from 'vue'
import { checkParams } from './check'

export const EmailMsg = {
    /**
	 * @description: 发送信息
	 * @param {String} account 消息账户
	 * @param {String} title 主题 必填
     * @param {String} content 正文 必填
     * @param {Array} filePaths 附件
     * @param {Array} userList 收件人 必填
     * @param {Array} ccUserList 抄送人
	 */
    async sendMsg (account=checkParams('消息账户'), title=checkParams('主题'), content=checkParams('正文'), filePaths, userList=checkParams('收件人'), ccUserList) {
        let params = {
            account,
            title,
            content,
            filePaths,
            userList: typeof userList === 'object' ? userList : [userList],
            ccUserList: typeof ccUserList === 'object' ? ccUserList : [ccUserList]
        }
        let res = await Vue.prototype.$request({
            url: "/web/apps/gongqi.os.msgnotify/Mail/sendMessage",
            method: "post",
            data: params
          })
        if (res.errcode !== 0) {
            throw new Error(res.errmsg)
        }
    }
}